%%%-------------------------------------------------------------------
%%% File    : svc_rpool_sup.erl
%%% Author  :  <vjache>
%%% Description : 
%%%
%%% Created :  2 Jul 2009 by  <vjache>
%%%-------------------------------------------------------------------
-module(svc_rpool_sup).

-behaviour(supervisor).

%% API
-export([start_link/1]).

%% Supervisor callbacks
-export([init/1]).

-define(SERVER, dmtr_rpools).

%%====================================================================
%% API functions
%%====================================================================
%%--------------------------------------------------------------------
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the supervisor
%%--------------------------------------------------------------------
start_link(PoolConfigList) ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, [PoolConfigList]).

%%====================================================================
%% Supervisor callbacks
%%====================================================================
%%--------------------------------------------------------------------
%% Func: init(Args) -> {ok,  {SupFlags,  [ChildSpec]}} |
%%                     ignore                          |
%%                     {error, Reason}
%% Description: Whenever a supervisor is started using 
%% supervisor:start_link/[2,3], this function is called by the new process 
%% to find out about restart strategy, maximum restart frequency and child 
%% specifications.
%%--------------------------------------------------------------------
init([PoolConfigList]) ->
%% 	PoolName,CacheMaxSize,CleanFactor,ResourceFactory
    APools = [
			   {_PName=element(1,PoolConfig),
				{svc_rpool,start_link,[PoolConfig]},
				permanent,
				2000,
				worker,
				[svc_rpool]
			   }||PoolConfig<-PoolConfigList],
    {ok,{{one_for_one,0,1}, APools}}.

%%====================================================================
%% Internal functions
%%====================================================================


